package org.spruice;

import java.util.HashMap;
import java.util.Map;

public class UniqueAutoNamer implements AutoNamer {
    private final Map<String, Integer> names = new HashMap<String, Integer>();

    public String next(Class clzz) {
        String className = clzz.getSimpleName();

        if (names.containsKey(className))
            names.put(className, names.get(className) + 1);
        else
            names.put(className, 0);

        StringBuilder builder = new StringBuilder("SpruiceAutoName-");
        builder.append(className);
        builder.append("#");
        builder.append(names.get(className));
        return builder.toString();
    }

}
